package ymr.gui;

import java.awt.Color;

import javax.swing.JFrame;

import ymr.game.Player;


/**
 * Java frame which keeps all necessary parts of the board in itself
 *
 */
public class MainWindow extends JFrame{

	private static final long serialVersionUID = 1L;
	
	/**
	 * constructor
	 */
	public MainWindow (){
		//for locating parts of window freely
		setLayout(null);
		//create new rectangle-shaped tile, set location on frame and add it to frame
		TileGUI b1 = new TileGUI("One");
		b1.setLocation(10, 10);
		add(b1);
		TileGUI b2 = new TileGUI("Two");
		b2.setLocation(120, 10);
		add(b2);
		TileGUI b3 = new TileGUI("Three");
		b3.setLocation(230, 10);
		add(b3);
		TileGUI b4 = new TileGUI("Four");
		b4.setLocation(340, 10);
		add(b4);
		TileGUI b5 = new TileGUI("Five");
		b5.setLocation(450, 10);
		add(b5);
		TileGUI b6 = new TileGUI("Six");
		b6.setLocation(450, 120);
		add(b6);
		TileGUI b7 = new TileGUI("Seven");
		b7.setLocation(450, 230);
		add(b7);
		TileGUI b8 = new TileGUI("Eight");
		b8.setLocation(450, 340);
		add(b8);
		TileGUI b9 = new TileGUI("Nine");
		b9.setLocation(450, 450);
		add(b9);
		TileGUI b10 = new TileGUI("Ten");
		b10.setLocation(450, 560);
		add(b10);
		TileGUI b11 = new TileGUI("Eleven");
		b11.setLocation(340, 560);
		add(b11);
		TileGUI b12 = new TileGUI("Twelve");
		b12.setLocation(230, 560);
		add(b12);
		TileGUI b13 = new TileGUI("Thirteen");
		b13.setLocation(120, 560);
		add(b13);
		TileGUI b14 = new TileGUI("Fourteen");
		b14.setLocation(10, 560);
		add(b14);
		TileGUI b15 = new TileGUI("Fifteen");
		b15.setLocation(10, 450);
		add(b15);
		TileGUI b16 = new TileGUI("Sixteen");
		b16.setLocation(10, 340);
		add(b16);
		
		//add info label
		InfoLabel il = new InfoLabel();
		il.setLocation (10, 200);
		add(il);
	
		
	}

	/**
	 * Create new button which marks how far player has moved on board 
	 * @param pl - player whose button this is
	 * @param colorNo - number of color which will be used to color button
	 */
	public void addButton(Player pl, Color colorNo){
		int x = pl.getLocation().getXcoord();
		int y = pl.getLocation().getYcoord();
		int diameter = 20;
		Button b1 = new Button(diameter, colorNo);
		pl.setButton(b1);
		b1.setLocation(x,y);
		add(b1);
		super.repaint();
	}
	
	public void removeButton(Button b){
		remove(b);
		super.repaint();
	}
	
	
	
	
}
